<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <h2 class="title">房产经纪</h2>
      </div>
      <div class="location">
        <div class="title">区域</div>
        <ul>
          <li><a href="#">天河</a></li>
          <li><a href="#">白云</a></li>
          <li><a href="#">番禺</a></li>
          <li><a href="#">海珠</a></li>
          <li><a href="#">黄埔</a></li>
          <li><a href="#">越秀</a></li>
          <li><a href="#">南沙</a></li>
          <li><a href="#">从化</a></li>
        </ul>
      </div>
      <el-row v-for="item in agentsList" :key="item.id">
        <el-col
          class="content"
          @click.native="$router.push(`/property/${item.id}`)"
        >
          <div class="content-image">
            <img
              v-fixImg="require('@/assets/defaultAvator.png')"
              :src="item.image"
              alt=""
              class="image"
            />
          </div>
          <div class="content-text">
            <h1 class="content-text-name">{{ item.name }}</h1>
            <div class="content-text-desc">{{ item.desc }}</div>
          </div></el-col
        >
      </el-row>
      <!-- 分页器 -->
      <el-pagination
        background
        layout="prev, pager, next"
        :total="total"
        @current-change="currentChange"
        :page-size="limit"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
import { getAgents, AgentNumber } from "@/api/agents";
export default {
  data() {
    return {
      agentsList: [],
      limit: 5,
      start: 0,
      total: 0,
    };
  },
  created() {
    this.getAgentsList();
  },
  methods: {
    async getAgentsList() {
      const res = await getAgents({
        _limit: this.limit,
        _start: this.start,
      });
      // console.log(res.data, 30);
      this.agentsList = res.data;
      const result = await AgentNumber();
      // console.log(result.data, 58);
      this.total = result.data;
    },
    // 分页器
    currentChange(currentPage) {
      // 从下标0开始算 第二条就是下标5开始
      this.start = currentPage * 5 - 5;
      this.getAgentsList();
    },
  },
};
</script>

<style lang="scss" scoped>
.title {
  text-align: start;
  margin-left: 150px;
}
.el-row {
  width: 95%;
  :hover {
    background-color: #f9f9f9;
  }
}
.content {
  width: 85%;
  height: 250px;
  // background-color: pink;
  display: flex;
  justify-content: center;
  text-align: start;
  border: 1px solid #ebeef5;
  border-radius: 5px;
  margin-top: 20px;
  margin-left: 200px;
}
.content-image {
  width: 200px;
  height: 200px;
  // background-color: blue;
  line-height: 200px;
  margin-top: 20px;
  border-right: 1px solid #ebeef5;
}
.image {
  vertical-align: middle;
  width: 150px;
  height: 150px;
  // background-color: green;
}
.content-text {
  width: 70%;
  // background-color: purple;
  padding-top: 20px;
  border-left: 1px solid #ebeef5;
}
.content-text-name {
  text-align: center;
}
.content-text-desc {
  padding-left: 50px;
}
.el-pagination {
  padding-top: 20px;
}
.location{
  height: 50px;
  line-height: 50px;
  margin-left: 250px;
  // background-color: blue;
  display: flex;
  font-size: 18px;
  .title{
    font-weight: 700;
    font-size: 20px;
  }
  ul{
    display: flex;
    margin-left:80px;
     :hover{
          color: #3072f6;
        }
    li{
      margin-right:28px;
      a{
        text-decoration:none;
        color:#0b0f12;
       
      }
    }
  }
}
</style>